#pragma once

#include <map>
#include <string>
#include <sstream>
#include <cstdio>
#include <iostream>
#include <fstream>

#define LOG (*params::err_log_file)
#define LOG_ASSERT(cond, ss) if (!(cond)) { LOG << ss << endl; abort(); }

namespace params {

extern std::ofstream *err_log_file;

extern std::map<std::string, std::string> raw_data;

template<class T>
T get(const char *name, const T& default_value)
{
	if (raw_data.find(string(name)) == raw_data.end())
		return default_value;
	else {
		istringstream is(raw_data[string(name)]);
		T ret;
		is >> ret;
		return ret;
	}
}

template<class T>
void put(const char *name, const T& value)
{
	ostringstream os(raw_data[string(name)]);
	os << value;
	raw_data[string(name)] = os.str();
}

extern void init(const char *filename = "UserAI.ini");

}